#include "PWM.h"

void initPWM(void)
{
    PWMCON0 = PWMCN0;
    PWMCON1 = PWMCN1;
    PWMCON2 = PWMCN2;
}

void PWM_SetPeriod(uint8 chn, uint16 period)
{
    uint8 temp;

    temp = PWMTH;
    if(chn < PWM_CHN4)
    {
        temp &= 0b11111100;
        temp |= (period>>8);
        PWMTH = temp;
        PWMTL = period & 0x00FF;
    }
    else
    {
        temp &= 0b11110011;
        temp |= (period>>8);
        PWMTH = temp;
        PWMT4L = period & 0x00FF;
    }
}


